//
//  QDetailsOrderCell.m
//  QoilPublic
//
//  Created by 杨凯 on 16/7/7.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "QDetailsOrderCell.h"

@interface QDetailsOrderCell()

@property (weak, nonatomic) IBOutlet UIImageView *lineImageView;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *lineConstr;

@property (weak, nonatomic) IBOutlet UILabel *ydpayLabel;

@end
@implementation QDetailsOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.lineImageView.backgroundColor = [QColorUtility defaultLineColor];
    self.lineConstr.constant = 0.5;
    
    _ydpayLabel.layer.cornerRadius = 4.0;
    _ydpayLabel.layer.borderColor = [QColorUtility defaultRedColor].CGColor;
    _ydpayLabel.layer.borderWidth = 0.5;
    _ydpayLabel.layer.masksToBounds = YES;
}

- (void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;

        if(_indexPath.section == 0){
            _subTitleLabel.textColor = [QColorUtility defaultBlueColor];
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
        }else if (_indexPath.section == 1 && _indexPath.row == 0){
            _subTitleLabel.textColor = [QColorUtility defaultRedColor];
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
        }else if (_indexPath.section == 1 && _indexPath.row == 1){
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
            _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 1 && _indexPath.row == 2){
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
            _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 1 && _indexPath.row == 3){
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
            _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 1 && _indexPath.row == 4){
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
            _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 1 && _indexPath.row == 5){
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
            _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 1 && _indexPath.row == 6){
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
            _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 3 && _indexPath.row == 0){
            _rightLabel.hidden = NO;
            _subTitleLabel.hidden = YES;
            _rightLabel.textColor = [QColorUtility defaultRedColor];
        }else if (_indexPath.section == 3 && _indexPath.row == 1){
            _rightLabel.hidden = NO;
            _subTitleLabel.hidden = YES;
            _rightLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 3 && _indexPath.row == 2){
            _rightLabel.hidden = NO;
            _subTitleLabel.hidden = YES;
            _rightLabel.textColor = [QColorUtility defaultRedColor];
        }else if (_indexPath.section == 5){//小票
            _rightLabel.hidden = NO;
            _subTitleLabel.hidden = YES;
            _rightLabel.textColor = [QColorUtility defaultDeepGrayColor];
        }else if (_indexPath.section == 6){//订单创建时间
            _rightLabel.hidden = YES;
            _subTitleLabel.hidden = NO;
            _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
        
        }
}

- (void)setModel:(QAllorderListModel *)model{
    _model = model;
        if(_model){
            if(_indexPath.section == 0){
                _ydpayLabel.hidden = YES;
                if([_model.orderState intValue] == 0){
                    _subTitleLabel.text = @"已下单";
                }else if ([_model.orderState intValue] == 1){
                    _subTitleLabel.text = @"完成支付";//**********
                }else if ([_model.orderState intValue] == 2){
                    _subTitleLabel.text = @"配送中";//13加油中//在路上
                }else if ([_model.orderState intValue] == 3){
                    _subTitleLabel.text = @"待评价";//*************
                }else if ([_model.orderState intValue] == 4){
                    _subTitleLabel.text = @"订单结束";
                }else if ([_model.orderState intValue] == 5){
                    _subTitleLabel.text = @"订单作废";
                }else if ([_model.orderState intValue] == 6){
                    _subTitleLabel.text = @"已送达";//*********
                }else if ([_model.orderState intValue] == 7){
                    _subTitleLabel.text = @"司机已送达";
                }else if ([_model.orderState intValue] == 8){
                    _subTitleLabel.text = @"待退款";
                }else if ([_model.orderState intValue] == 9){
                    _subTitleLabel.text = @"挂单";
                }else if ([_model.orderState intValue] == 10){
                    _subTitleLabel.text = @"已拒单";
                }else if ([_model.orderState intValue] == 11){
                    _subTitleLabel.text = @"订单已取消";
                }else if ([_model.orderState intValue] == 12){
                    _subTitleLabel.text = @"退款中";
                }else if ([_model.orderState intValue] == 13){
                    _subTitleLabel.text = @"加油中";
                }else if ([_model.orderState intValue] == 14){
                    _subTitleLabel.text = @"审核成功";
                }
            }else if (_indexPath.section == 1 && _indexPath.row == 0){
                
                if ([_model.orderState intValue] == 1||[_model.orderState intValue] == 3||[_model.orderState intValue] == 6) {
                    _subTitleLabel.text = [NSString stringWithFormat:@"￥%@",_model.total];
                    
                }else{
                    _subTitleLabel.text = @"服务未完成待结算";
                    
                }
                
                if([_model.desc isEqualToString:@"油到付款"]){
                    _ydpayLabel.hidden = NO;
                }else{
                    _ydpayLabel.hidden = YES;
                }
            }else if (_indexPath.section == 1 && _indexPath.row == 1){
                _subTitleLabel.text =[NSString stringWithFormat:@"%@元/升",_model.oilPrice];
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 1 && _indexPath.row == 2){
                _subTitleLabel.text = _model.oilType;
                _ydpayLabel.hidden = YES;
                
            }else if (_indexPath.section == 1 && _indexPath.row == 3){
                _subTitleLabel.text = [NSString stringWithFormat:@"%@",_model.serviceTime];
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 1 && _indexPath.row == 4){
                _subTitleLabel.text = _model.address;
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 1 && _indexPath.row == 5){
                _subTitleLabel.text = _model.userTel;
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 1 && _indexPath.row == 6){
                _subTitleLabel.text = @"否";
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 3 && _indexPath.row == 0){
                if ([_model.orderState intValue] == 1||[_model.orderState intValue] == 3||[_model.orderState intValue] == 6) {
                    _rightLabel.text = [NSString stringWithFormat:@"￥%@",_model.total];
                    
                }else{
                    _rightLabel.text = @"服务未完成待结算";
                    
                }
                
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 3 && _indexPath.row == 1){
                if ([_model.couponRemark isEqualToString:@""]) {
                    _rightLabel.text = @"未使用";
                }else{
                    _rightLabel.text = _model.couponRemark;
                }
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 3 && _indexPath.row == 2){
                if ([_model.orderState intValue] == 1||[_model.orderState intValue] == 3||[_model.orderState intValue] == 6) {
                    _rightLabel.text = [NSString stringWithFormat:@"￥%@",_model.sum];
                    
                }else{
                    _rightLabel.text = @"服务未完成待结算";
                    
                }
                _ydpayLabel.hidden = YES;
            }else if(_indexPath.section == 5){
                _ydpayLabel.hidden = YES;
                if(_model.imgs.count > 0){
                    _rightLabel.text = [NSString stringWithFormat:@"共%ld张",_model.imgs.count];
                }else{
                    _rightLabel.text = @"未上传";
                }
            } else if (_indexPath.section == 6 && _indexPath.row == 0){
                _subTitleLabel.text = _model.orderId;
                _ydpayLabel.hidden = YES;
            }else if (_indexPath.section == 6 && _indexPath.row == 1){
                _subTitleLabel.text = _model.creatime;
                _ydpayLabel.hidden = YES;
            }
        }
}


@end
